
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//方式一
int my_strcmp1(char* str1, char* str2)
{
	if (str1 == NULL || str2 == NULL)
		return 0;
	
	int i = 0;
	int len = 0;
	if (strlen(str1) > strlen(str2))
	{
		len = strlen(str1);
	}
	else len = strlen(str2);
	for (;i < len; i++)
	{
		if (str1[i] > str2[i])
		{
			return 1;
		}
		else if (str1[i] < str2[i])
		{
			return -1;
		}
	}
	return 0;
}

//方式二

int main()
{
	char str1[] = "hallooooooo";
	char str2[] = "hallowewe";
	int ret = my_strcmp1(str1,str2);
	//int ret = my_strcmp2(str1, str2);
	printf("%d\n", ret);
	system("pause");
	return EXIT_SUCCESS;
}
